package main

import "fmt"

type method_struct struct {
	Name string
	Age int
}

func (s *method_struct)String()string{
	str := fmt.Sprintf("name = %v, age = %v", s.Name, s.Age)
	return str
}

func main() {
	s := &method_struct{
		Name:"haha",
		Age:12,
	}
	//如果结构体实现了String方法则输出时自动调用
	//类似于toString
	fmt.Println(s)
}